package demo1;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;

/**
 * @Auther: 杨通通
 * @Date: 2024/10/22 00:05
 * @Description:
 */
public class MyBlockQueue {
    private Queue<String> list = new LinkedList<>();

    public synchronized void add(String str){
        list.add(str);
        this.notify();
    }

    public synchronized String get() throws InterruptedException {
        while (list.isEmpty()){
            this.wait();
        }
        return list.remove();
    }
}